// 应用信息类型
export interface AppInfo {
  name: string;
  version: string;
  description?: string;
  logo?: string;
  author?: string;
  homepage?: string;
  repository?: string;
  license?: string;
  buildTime?: string;
  commitHash?: string;
  environment: "development" | "staging" | "production";
  features: string[];
  config: {
    apiUrl: string;
    wsUrl?: string;
    cdnUrl?: string;
    maxFileSize: number;
    supportedFileTypes: string[];
    enableAnalytics: boolean;
    enableErrorReporting: boolean;
    maintenanceMode: boolean;
  };
}

// 系统状态类型
export interface SystemStatus {
  status: "healthy" | "degraded" | "down" | "maintenance";
  uptime: number;
  lastCheck: string;
  services: ServiceStatus[];
  metrics: SystemMetrics;
  alerts: SystemAlert[];
}

export interface ServiceStatus {
  name: string;
  status: "healthy" | "degraded" | "down";
  responseTime?: number;
  lastCheck: string;
  error?: string;
  dependencies?: string[];
}

export interface SystemMetrics {
  cpu: {
    usage: number;
    cores: number;
  };
  memory: {
    used: number;
    total: number;
    percentage: number;
  };
  disk: {
    used: number;
    total: number;
    percentage: number;
  };
  network: {
    inbound: number;
    outbound: number;
  };
  requests: {
    total: number;
    perSecond: number;
    avgResponseTime: number;
    errorRate: number;
  };
}

export interface SystemAlert {
  id: string;
  type: "info" | "warning" | "error" | "critical";
  title: string;
  message: string;
  source: string;
  createdAt: string;
  resolved: boolean;
  resolvedAt?: string;
  metadata?: Record<string, any>;
}

// 健康检查类型
export interface HealthCheck {
  status: "pass" | "fail" | "warn";
  version: string;
  releaseId: string;
  notes?: string[];
  output?: string;
  checks: Record<
    string,
    {
      status: "pass" | "fail" | "warn";
      time: string;
      output?: string;
    }
  >;
  links?: Record<string, string>;
}

// 系统统计类型
export interface SystemStats {
  users: {
    total: number;
    active: number;
    online: number;
    newToday: number;
  };
  sessions: {
    total: number;
    active: number;
    avgDuration: number;
  };
  conversations: {
    total: number;
    today: number;
    avgLength: number;
  };
  messages: {
    total: number;
    today: number;
    avgPerConversation: number;
  };
  personas: {
    total: number;
    active: number;
    popular: Array<{
      id: string;
      name: string;
      usage: number;
    }>;
  };
  knowledge: {
    bases: number;
    documents: number;
    totalSize: number;
  };
  performance: {
    avgResponseTime: number;
    errorRate: number;
    uptime: number;
  };
}

// 通知类型
export interface Notification {
  id: string;
  type: "info" | "success" | "warning" | "error";
  title: string;
  message: string;
  read: boolean;
  createdAt: string;
  expiresAt?: string;
  actionUrl?: string;
  actionText?: string;
  metadata?: Record<string, any>;
  userId?: string;
  global?: boolean;
}

// 公告类型
export interface AnnouncementData {
  id: string;
  type: "maintenance" | "feature" | "update" | "general";
  title: string;
  content: string;
  priority: "low" | "medium" | "high" | "urgent";
  active: boolean;
  startDate: string;
  endDate?: string;
  targetUsers?: string[];
  dismissible: boolean;
  dismissed?: boolean;
  createdAt: string;
  updatedAt: string;
  metadata?: Record<string, any>;
}

// 功能限制类型
export interface FeatureLimits {
  plan: "free" | "pro" | "enterprise";
  limits: {
    conversations: {
      daily: number;
      monthly: number;
      concurrent: number;
    };
    messages: {
      daily: number;
      monthly: number;
      maxLength: number;
    };
    personas: {
      custom: number;
      concurrent: number;
    };
    knowledge: {
      bases: number;
      documents: number;
      totalSize: number;
    };
    files: {
      maxSize: number;
      dailyUploads: number;
      supportedTypes: string[];
    };
    api: {
      requestsPerMinute: number;
      requestsPerDay: number;
    };
  };
  usage: {
    conversations: {
      daily: number;
      monthly: number;
      concurrent: number;
    };
    messages: {
      daily: number;
      monthly: number;
    };
    personas: {
      custom: number;
      concurrent: number;
    };
    knowledge: {
      bases: number;
      documents: number;
      totalSize: number;
    };
    files: {
      dailyUploads: number;
    };
    api: {
      requestsPerMinute: number;
      requestsPerDay: number;
    };
  };
  resetDates: {
    daily: string;
    monthly: string;
  };
}

// 面包屑导航类型
export interface BreadcrumbItem {
  label: string;
  path?: string;
  icon?: string;
  disabled?: boolean;
  metadata?: Record<string, any>;
}

// 错误类型
export interface AppError {
  id: string;
  type:
    | "network"
    | "validation"
    | "permission"
    | "server"
    | "client"
    | "unknown";
  code?: string | number;
  message: string;
  details?: string;
  stack?: string;
  timestamp: string;
  url?: string;
  userId?: string;
  sessionId?: string;
  metadata?: Record<string, any>;
  resolved?: boolean;
  retryable?: boolean;
}

// 快捷键类型
export interface Shortcut {
  id: string;
  key: string;
  description: string;
  action: string;
  category: "navigation" | "editing" | "general" | "chat";
  enabled: boolean;
  global?: boolean;
}

// 活动跟踪类型
export interface UserActivity {
  lastActive: string;
  isActive: boolean;
  idleTime: number;
  sessionStart: string;
  pageViews: number;
  interactions: number;
}

// 在线状态类型
export interface OnlineStatus {
  isOnline: boolean;
  lastOnline?: string;
  connectionType?: "wifi" | "cellular" | "ethernet" | "unknown";
  effectiveType?: "slow-2g" | "2g" | "3g" | "4g";
}

// 应用设置类型
export interface AppSettings {
  theme: "light" | "dark" | "auto";
  language: string;
  timezone: string;
  dateFormat: string;
  timeFormat: "12h" | "24h";
  notifications: {
    desktop: boolean;
    sound: boolean;
    email: boolean;
    push: boolean;
  };
  privacy: {
    analytics: boolean;
    errorReporting: boolean;
    dataCollection: boolean;
  };
  accessibility: {
    highContrast: boolean;
    largeText: boolean;
    reduceMotion: boolean;
    screenReader: boolean;
  };
  performance: {
    animations: boolean;
    autoSave: boolean;
    preloadImages: boolean;
    cacheSize: number;
  };
  shortcuts: Shortcut[];
}

// 导出所有类型
export type {
  AppInfo,
  SystemStatus,
  ServiceStatus,
  SystemMetrics,
  SystemAlert,
  HealthCheck,
  SystemStats,
  Notification,
  AnnouncementData,
  FeatureLimits,
  BreadcrumbItem,
  AppError,
  Shortcut,
  UserActivity,
  OnlineStatus,
  AppSettings,
};
